package com.itheima.system.exception;

import com.itheima.results.ErrorCode;

public class SystemException extends RuntimeException {
    private String code;

    private String text;

    public SystemException(String code) {
        this.code = code;
    }

    public SystemException(String code, String message) {
        super(message);
        this.code = code;
        this.text = message;
    }

    public SystemException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.name();
        this.text = errorCode.getMessage();
    }

    public SystemException(ErrorCode errorCode, String message) {
        super(message);
        this.code = errorCode.name();
        this.text = message;
    }

    public SystemException(ErrorCode errorCode, Throwable cause) {
        super(cause);
        this.code = errorCode.name();
        this.text = cause.getMessage();
    }

    public SystemException(String code, StackTraceElement[] stackTraceElements) {
        this.code = code;
        setStackTrace(stackTraceElements);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

}
